package com.briup.estore.service.impl;

import com.briup.estore.common.utils.PageUtils;
import com.briup.estore.entity.vo.CategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.briup.estore.common.utils.Query;

import com.briup.estore.dao.CategoryDao;
import com.briup.estore.entity.CategoryEntity;
import com.briup.estore.service.CategoryService;


@Service("categoryService")
public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService {

    @Autowired
    private  CategoryDao categoryDao;

    @Override
    public List<CategoryVO> findAllCategory() {
        //ArrayList arrayList = new ArrayList();
        ////一级分类
        //List<CategoryEntity> list = categoryDao.selectList(new QueryWrapper<CategoryEntity>().isNull("parent_id"));
        //for (CategoryEntity entity : list) {
        //    CategoryVO vo = new CategoryVO();
        //    vo.setId(entity.getId());
        //    vo.setName(entity.getName());
        //    //查询当前一级分类的二级分类
        //    List<CategoryEntity> categoryEntityList = categoryDao.selectList(new QueryWrapper<CategoryEntity>().eq("parent_id", entity.getId()));
        //    vo.setCategoryEntities(categoryEntityList);
        //    arrayList.add(vo);
        //}
        //return arrayList;

        List<CategoryVO> list = categoryDao.findAll();
        return  list;
    }
}